﻿<%@ Page Language="C#" %>

<%@ Import Namespace="System.Web.Script.Serialization" %>

<!DOCTYPE html>

<script runat="server">

  protected void Page_Load(object sender, EventArgs e)
  {
    string B2C_CODE = HttpContext.Current.Request["B2C_CODE"];
    string Mail = HttpContext.Current.Request["Mail"];
    SendNoticeProductMail(B2C_CODE, Mail);
  }
 
  
  public void SendNoticeProductMail(string b2c_code, string mail_address)
  { 
    try
    {
      B2C_MALL_HOME ws = new B2C_MALL_HOME();
      ws.Url = ConfigurationManager.AppSettings["B2C_MALL_HOME"].ToString(); 
      string jsonString = ws.B2C_MALL_GetProductDetail(ConfigurationManager.AppSettings["WebDeviceid"].ToString(),
        HttpContext.Current.User.Identity.Name, b2c_code);
      JObject restoredObject = JsonConvert.DeserializeObject<JObject>(jsonString);
      string Is_Valid = restoredObject["Is_Valid"].ToString();
      string msg = restoredObject["Msg"].ToString();
      if (Is_Valid == "Y")
      {
        //商品代號
        lbl_B2C_CODE.Text = Server.HtmlEncode(b2c_code);
        //商品名稱
        dynamic b2cCodeAry = restoredObject["B2C_CODE_ary"];
        lbl_B2C_CODE_NAME.Text = b2cCodeAry[0].B2C_CODE_NAME;
        //商品圖片
        dynamic imagePathAry = restoredObject["IMAGE_PATH_M_Ary"];
        ImageLink.ImageUrl = imagePathAry[0].IMAGE_PATH_M;
        ImageLink.NavigateUrl = System.Configuration.ConfigurationManager.AppSettings["SMTP_UrlDomain"].ToString() 
          + "/Products/ProductDetail.aspx?B2C_CODE=" + b2c_code;
        //商品價格
        dynamic priceAry = restoredObject["Prd_PRICE_Ary"];
        lbl_ACT_PRICE.Text = priceAry[0].ACT_PRICE;
        //網站URL
        WebLink.Text = System.Configuration.ConfigurationManager.AppSettings["SMTP_UrlDomain"].ToString();
        WebLink.NavigateUrl = System.Configuration.ConfigurationManager.AppSettings["SMTP_UrlDomain"].ToString();
        //傳送MAIL
        PanelAbout.Visible = true;
        MailUtility.SendHTMLMail("Shopping@evaair.com", 
          mail_address, 
          "[長榮樂e購]" + b2cCodeAry[0].B2C_CODE_NAME, 
          PanelAbout);
        PanelAbout.Visible = false;
      }
      else
      {
        throw new Exception(msg);
      }
    }
    catch (Exception ex)
    {
      throw ex;
    }    
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title></title>
</head>
<body>
  <form id="form1" runat="server">
    <div>
      <asp:Panel ID="PanelAbout" runat="server">
        <strong>親愛的樂e購貴賓您好，您感興趣的商品資訊如下：</strong>
        <asp:HyperLink ID="ImageLink" runat="server" />
        <br/>
        商品代碼 : <strong><asp:Label ID="lbl_B2C_CODE" runat="server" /></strong>
        <br/>
        商品名稱 : <strong><asp:Label ID="lbl_B2C_CODE_NAME" runat="server" /></strong>
        <br/>
        特價 : <strong><asp:Label ID="lbl_ACT_PRICE" runat="server" /></strong>
        <br/>   
        長榮樂e購網站 : <strong><asp:HyperLink ID="WebLink" runat="server" /></strong>
        <br/>   
        <div class="about">
          <div class="image">
            <%--<img id="ImgAbout" src="~/Images/ContentImages/contact.png" runat="server" />--%>
          </div>
          <div class="content-title">
            如果您對我們所提供的商品或是服務有任何疑問, 請利用以下方式:
          </div>
          <div class="content-bottom">
            <table>
              <tr>
                <th>客戶服務時間</th>
                <td>週一~週五 早上9:00~ 下午 5:00</td>
              </tr>
              <tr>
                <th>客戶服務熱線</th>
                <td>0800-535678</td>
              </tr>
              <tr>
                <th>電子郵件信箱</th>
                <td>
                  <a href="mailto:shopping@evaair.com">shopping@evaair.com</a>
                </td>
              </tr>
              <tr>
                <th>客戶服務傳真</th>
                <td>03-3510017,03-3510018</td>
              </tr>
            </table>
          </div>
        </div>
      </asp:Panel>
    </div>
  </form>
</body>
</html>
